<?php
class DBConnection {

	private $db;

	public function connect() {
		try {

			$server = "mysql10.000webhost.com";
			$port = "3306";
			$dbname = "a8793808_obd";
			$username = "a8793808_obd";
			$password = "obduser1234";
			$dsn = "mysql:host=$server;port=$port;dbname=$dbname";
			$this -> db = new PDO($dsn, $username, $password);
		} catch (PDOException $e) {
			echo "Could not connect to Database";
			echo $e -> getMessage();
		}
	}

	public function query($query, array $params) {
		try {
			$statement = $this -> db -> prepare($query);
			$statement -> execute($params);
//			print_r($statement->errorInfo());
			return $statement;
		} catch (PDOException $e) {
			echo "Query failed.";
			echo $e -> getMessage();
		}
		return false;
	}

}
?>